package com.stylefeng.guns.modular.goods.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.goods.model.SkuSpecValue;
import com.stylefeng.guns.modular.goods.service.ISkuSpecValueService;

/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2018-09-05 16:09:57
 */
@Controller
@RequestMapping("/skuSpecValue")
public class SkuSpecValueController extends BaseController {

    private String PREFIX = "/goods/skuSpecValue/";

    @Autowired
    private ISkuSpecValueService skuSpecValueService;

    /**
     * 跳转到首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "skuSpecValue.html";
    }

    /**
     * 跳转到添加
     */
    @RequestMapping("/skuSpecValue_add")
    public String skuSpecValueAdd() {
        return PREFIX + "skuSpecValue_add.html";
    }

    /**
     * 跳转到修改
     */
    @RequestMapping("/skuSpecValue_update/{skuSpecValueId}")
    public String skuSpecValueUpdate(@PathVariable Long skuSpecValueId, Model model) {
        SkuSpecValue skuSpecValue = skuSpecValueService.selectById(skuSpecValueId);
        model.addAttribute("item",skuSpecValue);
        LogObjectHolder.me().set(skuSpecValue);
        return PREFIX + "skuSpecValue_edit.html";
    }

    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return skuSpecValueService.selectList(null);
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(SkuSpecValue skuSpecValue) {
        skuSpecValueService.insert(skuSpecValue);
        return SUCCESS_TIP;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Long skuSpecValueId) {
        skuSpecValueService.deleteById(skuSpecValueId);
        return SUCCESS_TIP;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(SkuSpecValue skuSpecValue) {
        skuSpecValueService.updateById(skuSpecValue);
        return SUCCESS_TIP;
    }

    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{skuSpecValueId}")
    @ResponseBody
    public Object detail(@PathVariable("skuSpecValueId") Long skuSpecValueId) {
        return skuSpecValueService.selectById(skuSpecValueId);
    }
}
